package com.gluck.cases.core.modal.assemble;

import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @ClassName PageInfoAssemble
 * @Desc PageInfo 公共组装类
 * @Author shiyongzhe
 * @Date 2022/6/3 - 1:31 下午
 **/
public class PageInfoAssemble<T> {

    /**
     * 功能描述: pageinfo 公共转换dto 方法
     * @Params [result, target]
     * @Return com.github.pagehelper.PageInfo<T>
     * @Author I`m Gluck
     * @Date 2022/6/3
     */
    public PageInfo<T> covertDtoPageInfo(PageInfo<?> result, List<T> target){
        PageInfo<T> pageInfo = new PageInfo<>();
        pageInfo.setList(target);
        pageInfo.setEndRow(result.getEndRow());
        pageInfo.setHasNextPage(result.isHasNextPage());
        pageInfo.setIsFirstPage(result.isIsFirstPage());
        pageInfo.setPageNum(result.getPageNum());
        pageInfo.setPages(result.getPages());
        pageInfo.setTotal(result.getTotal());
        pageInfo.setSize(result.getSize());
        return pageInfo;
    }
}
